package com.byxy.ssm.demo.service.impl;

import java.util.List;

import javax.jws.soap.SOAPBinding.Use;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.byxy.ssm.demo.dao.UserDao;
import com.byxy.ssm.demo.entity.User;
import com.byxy.ssm.demo.service.UserService;
@Service
@Transactional
public class UserServiceImpl implements UserService{
	@Autowired
	private UserDao userDao;
	@Override
	public User login(String username, String password) {
		return userDao.login(username,password);
	}
	@Override
	public boolean reg(String username, String password, String userNick, Integer userType) {
		User user=userDao.getByUsername(username);
		if (user!=null) {
			return false;
		}
		userDao.add(new User(username, userNick, password, userType));
		return true;
	}
	@Override
	public User getUserById(Integer userId) {
		
		return userDao.getById(userId);
	}
	@Override
	public List<User> findAll() {
		
		return userDao.findAll();
	}
	@Override
	public User loginByName(String username) {
		return userDao.getByUsername(username);
	}
	
	
	
}
